package com.service;

import com.dao.airticle.ArticleDao;
import com.dao.userdao.PersonalCenter;
import com.pojo.Article;
import com.pojo.PageBean;
import com.pojo.User;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

public class ManagerService {
    /**
     * 通过博客
     */
     public static void pass_blog(HttpServletRequest req)throws IOException{
             String blog_id=req.getParameter("blog_id");
             ArticleDao.pass_blog(blog_id);
     }
    /**
     * 不通过博客
     */
    public static void not_pass_blog(HttpServletRequest req)throws IOException{
              String blog_id=req.getParameter("blog_id");
              ArticleDao.not_pass_blog(blog_id);
    }

    /**
     * 获取所有用户
     */
    public static PageBean<User> get_all_user(int currentPage)throws IOException{
        PageBean<User>pb=new PageBean<User>();
        pb.setCurrentPage(currentPage);
        pb.setPageSize(10);


        int totalCount= PersonalCenter.get_user_count();
        pb.setTotalCount(totalCount);

        int start=(currentPage-1)*10;
        List<User> list=PersonalCenter.get_all_user(start);
        pb.setList(list);

        int totalPage=totalCount%10==0?totalCount/10:(totalCount/10+1);
        pb.setTotalPage(totalPage);

        return pb;
    }
}
